package com.taobao.api.internal.tmc;

import java.io.Serializable;
import java.util.Map;

/**
 * 消息通道-通用消息结构。
 * 
 * @author fengsheng
 * @since 1.0, May 4, 2013
 */
public class Message implements Serializable {

  private static final long serialVersionUID = 3770198526461322514L;

  private Long              id;
  private String            topic;
  private String            pubAppKey;
  private String            userNick;
  private Long              bornTime;
  private String            content;
  private Long              userId;

  public Long getUserId() {
    return userId;
  }

  public void setUserId(Long userId) {
    this.userId = userId;
  }

  public Long getId() {
    return this.id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getTopic() {
    return this.topic;
  }

  public void setTopic(String topic) {
    this.topic = topic;
  }

  public String getPubAppKey() {
    return this.pubAppKey;
  }

  public void setPubAppKey(String pubAppKey) {
    this.pubAppKey = pubAppKey;
  }

  public String getUserNick() {
    return this.userNick;
  }

  public void setUserNick(String userNick) {
    this.userNick = userNick;
  }

  public Long getBornTime() {
    return this.bornTime;
  }

  public void setBornTime(Long bornTime) {
    this.bornTime = bornTime;
  }

  public String getContent() {
    return this.content;
  }

  public void setContent(String content) {
    this.content = content;
  }

  public static Message parse(Map<?, ?> map) {
    Message msg = new Message();
    msg.setId((Long) map.get("id"));
    msg.setTopic((String) map.get("topic"));
    msg.setPubAppKey((String) map.get("pub_app_key"));
    msg.setUserNick((String) map.get("user_nick"));
    msg.setUserId((Long) map.get("user_id"));
    msg.setBornTime((Long) map.get("born_time"));
    msg.setContent((String) map.get("content"));
    return msg;
  }

}
